home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
internet
/
yam_i_dodatki
/
yamscripts
/
addxheader.rexx
next >
Wrap
OS/2 REXX Batch file
|
1997-07-22
|
2KB
|
72 lines
/* AddXheader.rexx 1.1 by knikulai@utu.fi
** Adds X-Headers from a given file to all messages in the outgoing folder
** Check http://www.utu.fi/~knikulai/ARexx.html for more scripts or send mail
** to knikulai@utu.fi with word 'request' as subject and 'dir' in message body
**
** This version doesn't add same headers many times.
*/
options results
headers='YAM:xheaders' /* File to read headers from. Empty lines are ignored */
/* Header format is _NOT_ checked in any way, it's your */
/* responsibility */
tempfile='t:tmp.msg'
address 'YAM' /* Our favourite program.. */
if ~open(hdr,headers,'r') then do /* Something went wrong... Is the path correct? */
'Request "Could not open' headers'!" "_Ok"'
exit
end
/* Read the header file:*/
lines=0
do while ~eof(hdr)
li=strip(readln(hdr))
if li~='' then do /* Forget empty lines */
lines=lines+1
header.lines=li
end
end
call close(hdr)
'SetFolder 1'
'GetFolderInfo Max'
n=result
if n=0 then do
'Request "The Outgoing folder is empty!" "_Ok"'
exit
end
do m=0 to n-1
'SetMail' m /* Change message */
'GetMailInfo File' /* Get it's filename */
file=result
address command 'c:copy' file tempfile /* Copy the message */
call open(in,tempfile,'r') /* Open copy for reading */
call open(out,file,'w') /* Open message for rewrite */
body=0 /* This means we are still in headers */
add_here=0 /* Add headers when this is 1*/
do while ~eof(in)
li=readln(in) /* Read a line from copy */
if add_here & word(li,1)~=word(header.1,1) & ~body then do
body=1 /* Make sure we wont do this again */
do i=1 to lines /* Write all headers */
call writeln(out,header.i)
end
end /* if */
call writeln(out,li) /* Write the line */
/* Change the following line and you can decide after which header */
/* line the new lines are added. */
if word(li,1)='Message-ID:' & ~body then
add_here=1
else
add_here=0
end /* do while */
call close(in) /* Close copy */
call close(out) /* Close new message */
end
address command 'c:delete >nil:' tempfile /* Delete the copy of the last msg */
exit